package com.kucai.yifaqapp.presenter.activity;

import com.kucai.yifaqapp.global.HttpAdress;
import com.kucai.yifaqapp.model.CustomObserver;
import com.kucai.yifaqapp.model.network.HttpJsonUtils;
import com.kucai.yifaqapp.model.network.entity.res.ResActivity;
import com.kucai.yifaqapp.model.network.entity.res.ResActivitys;
import com.kucai.yifaqapp.ui.activity.AllActivity;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/12/8.
 */

public class AllActivityPresenter extends BaseActivityPresenter<AllActivity> {
    public AllActivityPresenter(AllActivity mActivity) {
        super(mActivity);
    }

    //获取活动信息
    public void getactivity() {
        HttpJsonUtils.getHttpApiInstance()
                .getactivity(HttpAdress.getuseAdress() + "api/m/lottery/getSourceData")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new CustomObserver<ResActivity>() {
                    @Override
                    protected void onCustomNext(ResActivity resActivity) {
                        if (null != resActivity.data.activity && resActivity.data.activity.data != null) {
                            mActivity.getActivity(resActivity);

                        }
                    }

                    @Override
                    protected void onSubscribeCustom(Disposable disposable) {
                    }

                    @Override
                    protected void onErrorCustom(Throwable e) {
                    }
                });
    }

    //获取游戏url
    public void getactivitys(int id, int imgid) {
        HttpJsonUtils.getHttpApiInstance()
                .getactivitys(HttpAdress.getuseAdress() + "api/m/lottery/getSourceActivty",id, imgid)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new CustomObserver<ResActivitys>(mActivity) {

                    @Override
                    protected void onCustomNext(ResActivitys resActivitys) {
                        if (resActivitys.data != null && resActivitys.data.content != null) {
                            mActivity.getActivitys(resActivitys);
                        }
                    }

                    @Override
                    protected void onSubscribeCustom(Disposable disposable) {
                    }

                    @Override
                    protected void onErrorCustom(Throwable e) {
//                        Toast.makeText(mFragment.getContext(), "开元游戏，获取失败", Toast.LENGTH_LONG).show();
                    }
                });
    }



}